package com.meisupic.copyright.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.meisupic.copyright.validategroups.AuthTypeGroup;
import com.meisupic.copyright.validategroups.EnterpriseAuthGroup;
import com.meisupic.copyright.validategroups.PersonAuthGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import javax.validation.constraints.Future;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.URL;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * @Author lanjian
 * @Date 2018/8/30 下午10:24
 */
@Data
@ApiModel
public class RealnameAuthApiVo implements Serializable {

  private static final long serialVersionUID = 6954289068456036105L;

  @ApiModelProperty(value = "实名认证id，修改实名认证时必填。")
  private Long id;

  /**
   * 企业或个人名称.
   */
  @NotBlank(message = "名称不能为空", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "企业或个人名称", required = true)
  private String authName;

  /**
   * 认证类型
   */
  @NotBlank(message = "认证类型不能为空", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class,
      AuthTypeGroup.class})
  @Pattern(regexp = "^person|enterprise$", groups = {PersonAuthGroup.class,
      EnterpriseAuthGroup.class,
      AuthTypeGroup.class}, message = "认证类型错误,只能为person或enterprise")
  @ApiModelProperty(value = "认证类型。person=个人、enterprise=企业", required = true, allowableValues = "person,enterprise")
  private String authType;


  /**
   * 证件类型.
   */
  @NotNull(message = "证件类型不能为空", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "证件类型。1=身份证、2=军官证、3=警官证、4=护照、5=企业法人营业执照、6=组织机构代码证书、7=事业单位法人证书、8=社团法人证书、9=其他有效证件。目前个人只支持身份证，企业使用企业法人营业执照（统一社会信用代码）", required = true, allowableValues = "1,2,3,4,5,6,7,8,9")
  private Integer documentType;

  /**
   * 证件号码.
   */
  @NotEmpty(message = "请输入证件号码", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "证件号码", required = true)
  private String documetNo;

  /**
   * 证件是否长期有效
   */
  @NotNull(message = "证件是否长期有效不能为空")
  @ApiModelProperty(value = "证件是否长期有效.0=否、1=是", required = true, allowableValues = "0,1")
  private Integer longTermEffective;

  /**
   * 失效日期
   */
  @Future(message = "证件有效期必须大于当前时间", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  @ApiModelProperty(value = "证件失效日期，当证件不为长期有效时必填")
  private Date invalidDate;

  /**
   * 证件照片正面图片地址
   */
  @NotEmpty(message = "请上传证件照片", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @URL(message = "证件正面地址不是正确的url地址")
  @ApiModelProperty(value = "证件照片正面地址,当认证类型为企业时为营业执照照片", required = true)
  private String documentImgPositiveUrl;

  /**
   * 证件反面照片
   */
  @NotEmpty(message = "请上传身份证反面照片", groups = {PersonAuthGroup.class})
  @ApiModelProperty(value = "证件照片反面地址，认证类型为企业时可不填")
  private String documentImgBackUrl;

  /**
   * 手机号码.
   */
  @Pattern(regexp = "^1(3|4|5|7|8)\\d{9}$", groups = {PersonAuthGroup.class,
      EnterpriseAuthGroup.class}, message = "请输入正确的手机号码")
  @NotBlank(message = "手机号码不能为空")
  @ApiModelProperty(value = "申请人手机号码", required = true)
  private String mobile;

  /**
   * 邮箱.
   */
  @Email(message = "请输入正确的邮箱地址", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @NotBlank(message = "邮箱地址不能为空")
  @ApiModelProperty(value = "申请人邮箱地址", required = true)
  private String email;

  @NotBlank(message = "请输入省份", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "申请人地址省份信息", required = true)
  private String province;

  @NotBlank(message = "请输入城市", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "申请人地址所在城市信息", required = true)
  private String city;

  @NotBlank(message = "请输入详细地址", groups = {PersonAuthGroup.class, EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "申请人详细地址信息", required = true)
  private String address;

  /**
   * 法人姓名
   */
  @NotBlank(message = "请输入法人姓名", groups = {EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "法人姓名，认证类型为企业时必填")
  private String legalName;

  /**
   * 法人身份号码.
   */
  @NotEmpty(message = "请输入法人身份证号码", groups = {EnterpriseAuthGroup.class})
  @ApiModelProperty(value = "法人身份证号码，认证类型为企业时必填")
  private String legalIdentityCardNo;

  /**
   * 法人身份证正面照片.
   */
  @NotEmpty(message = "缺少法人身份证正面照片", groups = {EnterpriseAuthGroup.class})
  @URL(message = "法人身份证正面照片不是正确url地址")
  @ApiModelProperty(value = "法人身份证正面照片地址，认证类型为企业时必填")
  private String corporateIdentityCardImgPositiveUrl;

  /**
   * 法人身份证反面照片.
   */
  @NotEmpty(message = "缺少法人身份证反面照片", groups = {EnterpriseAuthGroup.class})
  @URL(message = "法人身份证反面照片不是正确url地址")
  @ApiModelProperty(value = "法人身份证反面照片地址，认证类型为企业时必填")
  private String corporateIdentityCardImgBackUrl;

  @ApiModelProperty(hidden = true)
  private String clientId;

}
